package com.longge;

public class SortArrayByParity {
    public int[] sortArrayByParity(int[] nums) {


        int left = 0, right = nums.length - 1;

        while (left < right) {
            if (nums[left] % 2 == 0) {
                left++;
            } else {
                if (nums[right] % 2 == 0) {
                    int temp = nums[right];
                    nums[right] = nums[left];
                    nums[left] = temp;
                }
                right--;
            }

        }
        return nums;

    }
}
